package parts4.lesson38;

/**
 * 生产者
 */
public class DataProvider implements Runnable {
    private Data data;

    public DataProvider(Data data) {
        this.data = data;
    }

    @Override
    public void run() {
        for (int x = 0; x < 50; x++) {
            if (x % 2 == 0) {
                this.data.setTitle("老李");
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                this.data.setNote("是个好人");
            } else {
                this.data.setTitle("民族败类");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                this.data.setNote("是个坏人");
            }
        }
    }
}
